﻿from flask import Flask, render_template,jsonify,request
import jieba
import random
import recite2

app = Flask(__name__)

signs = ["，", "。", "！", "？", "“", "”", "《", "》", "（", "）", "\n","、"]
pattern = "['，。！？“”《》（）\n、']"
@app.route('/demo')
def demo():
    r"""
    宣染demo.html
    jjjjjjj
    Parameters
    ----------
    sep :  

    Returns
    -------
    html页面
    """
    return render_template("demo.html")

@app.route('/')
def simplejson():
    return render_template("brython.html")

@app.route('/simpleapi',methods=["GET"])
def simpleapi():
    return jsonify({"iss_position":"shanghai",
                    "timestamp":8888888})

@app.route('/qiaoqin')
def qiaoqin():
    return render_template("qiaoqin.html")

def replaceWord(x, s):
    res = []
    for i in x:
        if ord(i) > 126:
            res.append(s * 2)
        else:
            res.append(s)
    return "".join(res)
       
@app.route('/recite/<mode>/<text0>',methods=["GET"])
def recite(mode,text0):
    if mode == "1":
        res = recite2.reciteMode1(text0.replace("0000","\n"))
    elif mode == "2":
        res = recite2.reciteMode2(text0.replace("0000","\n"))
    else:
        res = recite2.reciteMode3(text0.replace("0000","\n"))
    return jsonify(list=res) 
   
if __name__ == '__main__':
    app.run(debug=True)
